package org.manon.json.util;

/**
 * Utility class for UTF-8 charset.
 * 
 * @author <a href="mailto:jacques.militello@gmail.com">Jacques Militello</a>
 */
public final class UTF8Util {

	private UTF8Util() {
	}

	public static final int decode(byte a, byte b) {
		return ((a & 0x1F) << 6) | (b & 0x3F);
	}

	public static final int decode(byte a, byte b, byte c) {
		return ((((a &= 0x0F) << 6) | (b & 0x3F)) << 6) | (c & 0x3F);
	}

	public static final int decode(byte a, byte b, byte c, byte d) {
		// to change....
		return (((((((a & 0x07) << 6) | (b & 0x3F)) << 6) | (c & 0x3F)) << 6) | (d & 0x3F)) - 0x10000;
	}

}